package com.secsbrain.development.biz.constant;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 环境标示
 * Created by yangyang.zhang on 2017/6/27.
 */
public enum Env {
    dev02, dev03, stable, test, pre3, pro3;

    public static List<Env> dev() {
        return Arrays.asList(dev02, dev03, stable);
    }

    public static List<Env> test() {
        return Collections.singletonList(test);
    }

    public static List<Env> pre() {
        return Collections.singletonList(pre3);
    }

    public static List<Env> prod() {
        return Collections.singletonList(pro3);
    }

    public static List<Env> online() {
        return Arrays.asList(pre3, pro3);
    }

    public static List<Env> offline() {
        return Arrays.asList(dev02, dev03, stable, test);
    }

    public static List<Env> permission(UserType userType) {
        switch (userType) {
            case DEV:
                List<Env> envs = new ArrayList<>();
                envs.addAll(online());
                envs.addAll(dev());
                return envs;
            case TEST:
                return Arrays.asList(values());
            case ADMIN:
                return Arrays.asList(values());
            default:
                return Collections.emptyList();
        }
    }

    public static String disconfEnv(Env env) {
        if (Env.dev().contains(env)) {
            return "dev";
        } else if (Env.test().contains(env)) {
            return "test";
        } else if (Env.pre().contains(env)) {
            return "pre3";
        } else {
            return "pro3";
        }
    }
}
